package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.ShoppingCart;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 根据用户id和商品/套餐id查询是否已存在
     * @param shoppingCart
     * @return
     */
    ShoppingCart getInfo(ShoppingCart shoppingCart);

    /**
     * 根据用户id和商品/套餐id修改数据
     * @param cartInfo
     */
    @AutoFill(OperationType.UPDATE)
    void updateInfo(ShoppingCart cartInfo);

    /**
     * 新增购物车
     * @param shoppingCart
     */
    @AutoFill(OperationType.INSERT)
    void add(ShoppingCart shoppingCart);

    /**
     * 查询购物车
     * @param shoppingCart
     * @return
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> selectList(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void delete(Long userId);

    /**
     * 删除购物车记录
     * @param id
     */
    @Delete("delete from shopping_cart where id = #{id}")
    void deleteByDishSetmealID(Long id);

    /**
     * 批量添加购物车数据
     * @param list
     */
    void batchAddList(List<ShoppingCart> list);
}
